home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / DMTDEMOS / SETATTR.DEM < prev    next >
Text File  |  1994-07-02  |  1KB  |  64 lines

  1. program SetAttrSample;
  2.  
  3.  uses crt, DMT;
  4.  
  5.  var
  6.    Attrib     : char;
  7.  
  8.    Attributes : word;
  9.  
  10.    FileName   : string;
  11.  
  12. begin
  13.   Color( 7, 0 );
  14.   clrscr;
  15.  
  16.   write( 'Set Attributes for, Enter filename : ' );
  17.   readln( FileName );
  18.  
  19.   { Get the current attributes for the file specified }
  20.  
  21.   GetAttr( FileName, Attributes );    { Call GetAttr procedure }
  22.  
  23.   writeln;
  24.   writeln('Available Attributes ');
  25.   writeln;
  26.   writeln('(1) Normal        (4) Read only');
  27.   writeln('(2) Hidden        (5) System   ');
  28.   writeln('(3) Archive ');
  29.   writeln;
  30.   write('Select (1..5) : ');
  31.  
  32.   repeat
  33.     Attrib := upcase( readkey );
  34.   until Attrib in['1'..'5'];
  35.  
  36.   writeln(Attrib);
  37.  
  38.  
  39.   { Add the attribute selected to the current attribute(s) }
  40.  
  41.   case Attrib of
  42.    '1' : Attributes := $00;                { Normal    }
  43.    '2' : Attributes := Attributes or $02;  { Hidden    }
  44.    '3' : Attributes := Attributes or $20;  { Archive   }
  45.    '4' : Attributes := Attributes or $01;  { Read Only }
  46.    '5' : Attributes := Attributes or $04;  { System    }
  47.   end;
  48.  
  49.   SetAttr( FileName, Attributes );   { Call SetAttr procedure }
  50.  
  51.   if ( ErrFlag ) then
  52.     begin
  53.       writeln( #7 );
  54.       writeln( ShowError( GetErrCode ) );
  55.     end
  56.   else
  57.     begin
  58.       writeln;
  59.       writeln( 'Done...' );
  60.     end;
  61.  
  62.   GetEnter;
  63. end.
  64.